package com.ruoyi.accounting.enums;

import java.util.Objects;

public enum AccountTypeEnum {
    CASH(1, "现金账户"),
    SAVINGS(2, "储蓄账户"),
    VIRTUAL(3, "虚拟账户"),
    INVESTMENT(4, "投资账户"),
    CREDITOR(5, "债权账户"),
    CREDIT_CARD(6, "信用账户"),
    LIABILITY(7, "负债账户");
    private final Integer code;
    private final String name;

    AccountTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static boolean isValidCode(Integer code) {
        for (AccountTypeEnum accountType : AccountTypeEnum.values()) {
            if (Objects.equals(accountType.getCode(), code)) {
                return true;
            }
        }

        return false;
    }

    public Integer getCode() {
        return code;
    }
}
